/**
 *
 * @author Anastasiya
 *
 */

#include "printing.h"

using namespace std;

bool Printer::terse = false;

const string Printer::MESSAGE_TEST_STARTED = "Test started on file ";
const string Printer::MESSAGE_TEST_ENDED = "Test ended on file ";
const string Printer::MESSAGE_TEST_FAILED = "Test failed on file ";

const string Printer::MESSAGE_STATUS_OK = " [OK]";
const string Printer::MESSAGE_STATUS_FAILED = " [FAILED]";

const string Printer::MESSAGE_ERROR = "Error: ";
const string Printer::MESSAGE_FAILED = "Failed: ";
const string Printer::MESSAGE_AT_FILE = " at ";


Printer::Printer(ostream* errorOutput, ostream* standardOutput){
	this->errorOutput = errorOutput;
	this->standardOutput = standardOutput;
}

Printer::~Printer(){
	errorOutput->flush();
	standardOutput->flush();
}

void Printer::testStarted(string filename){
	*standardOutput << MESSAGE_TEST_STARTED << filename << endl;
}

void Printer::testEnded(string filename){
	*standardOutput << MESSAGE_TEST_ENDED << filename << MESSAGE_STATUS_OK << endl;
}
void Printer::testFailed(string filename){
	*standardOutput << MESSAGE_TEST_FAILED << filename << MESSAGE_STATUS_FAILED << endl;
	*errorOutput << MESSAGE_FAILED <<  filename;
}

void Printer::logError(string message, string filename){
	*errorOutput << MESSAGE_ERROR << message << MESSAGE_AT_FILE<< filename << endl;
}

void Printer::logEvent(string messageEvent, string filename){
	if(!terse){
		*standardOutput << messageEvent << MESSAGE_AT_FILE << filename << endl;
	}
}
void Printer::logEvent(string messageEvent){
	if(!terse){
		*standardOutput << messageEvent << endl;
	}
}